<%@ page language="java" pageEncoding="utf-8"%>
<%@ page import="com.witframework.web.mvc.WebContext"%>
<%@ include file="/WEB-INF/classes/com/witframework/webroot/framework/common/taglibs.jsp"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">
<%@ include	file="/WEB-INF/classes/com/witframework/webroot/framework/common/meta.jsp"%>
<%@ include	file="/WEB-INF/classes/com/witframework/webroot/framework/common/componentsmeta.jsp"%>
<%
	WebContext webContext = new WebContext(request, response);
	String treeid = webContext.getParameterAndsetAttribute("treeid");
	String root = webContext.getParameterAndsetAttribute("root");
	//指向父节点的属性名称
	String parent = webContext.getParameterAndsetAttribute("parentid");

	String multiple = webContext.getParameterAndsetAttribute("multiple");
	multiple = (multiple == null ? "false" : multiple);
	int isradio = (multiple.equalsIgnoreCase("true") || multiple.equalsIgnoreCase("1")) ? 0 : 1;

	//默认的选中项
	String selected = webContext.getParameterAndsetAttribute("selected");

	String childrenData = "/dataSetAuthSelectTreeController.wit?" + request.getQueryString();

	String dialogHeight = webContext.getContextParameterAndsetAttribute("height");
	int height = (dialogHeight == null ? 450 : Integer.parseInt(dialogHeight));
	String dialogWidth = webContext.getContextParameterAndsetAttribute("width");
	int width = (dialogWidth == null ? 618 : Integer.parseInt(dialogWidth));
%>
<script>
isradio=<%=isradio%>;
function selectit(){	
	var p1="", p2="", p3="";	
	var selectedItems=tree.getAllChecked();		
	var items=selectedItems.split(",");
	if(items!="")
	for(i=0;i<items.length;i++){
		p1=p1+items[i]+",";		
		p2=p2+tree.getItemText(items[i])+",";		
		u=tree.getUserData(items[i],"others");			
		if(typeof u=='string')
			p3=p3+u+",";
	
	}		
	setSelected('${treeid}',p1.substring(0,p1.length-1),p2.substring(0,p2.length-1),p3.substring(0,p3.length-1));	
}
function reloadTree(){

}
</script
</head>
	<!-- 
					<div class="filter">
					<input id="itemlabel" size=10/>
					<a href="#" onclick="find(document.getElementById('itemlabel').value);" accesskey="f">
						<img src="${contextPath}/webresource/images/ico_btn_search.gif">
						查询(F)
					</a>					
					<a href="#" onclick="tree.refreshItem(0)" accesskey="r">
						<img src="${contextPath}/webresource/images/meta/refresh.png">						
					</a>
					</div>
	 -->			
<body id="treebox" >			
			<script type="">
			//tree=new dhtmlXTreeObject("treebox","<%=width - 38%>","<%=height - 38%>","<%=root%>");
			tree=new dhtmlXTreeObject("treebox","<%=width-28%>","<%=height-38%>","<%=root%>");
			tree.setImagePath("${contextPath}/webresource/components/tree/imgs/csh_winstyle/");
			tree.enableSmartXMLParsing(1);
			tree.enableSmartCheckboxes(0);
			tree.enableHighlighting(1);  
			tree.enableCheckBoxes(1,1);
			tree.enableRadioButtons(<%=isradio%>);			
			tree.enableAutoTooltips(1);
			tree.enableThreeStateCheckboxes(0);
			tree.enableFixedMode(1);
			//tree.enableTreeImages(0);
			tree.enableMultiLineItems(0);
			tree.setXMLAutoLoading("${contextPath}<%=childrenData%>");
			tree.loadXML("${contextPath}<%=childrenData%>&id=<%=root%>");
			tree.setOnCheckHandler(check);
			function find(label){
				tree.openAllItems(0);
				itemId=tree.findItem(label);				;				
			}
			function check(id,state){		
				if(isradio==1){		
					var selectedItems=tree.getAllChecked();		
					var items=selectedItems.split(",");
					for(i=0;i<items.length;i++){
						tree.setCheck(items[i],0);
					}
					tree.setCheck(id,state);
				}
				selectit();
			}			
			</script>
</body>
</html>